package club.monkeywood.handler;

import club.monkeywood.exception.SellException;
import club.monkeywood.vo.buyer.ServerResponseVO;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

//异常拦截类
@ControllerAdvice
public class SellExceptionHandler {

    //全局异常处理，返回异常json
    //处理异常：SellException
    @ExceptionHandler(value = SellException.class)
    @ResponseBody
    public ServerResponseVO handlerSellException(SellException e) {
        //将异常代码及描述返回给前端
        return ServerResponseVO.createByErrorCodeMessage(e.getCode(), e.getMessage());
    }

}
